﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnimalOnPropertyChange
{
    class Animal
    {
        const string PropertyName = "Name";
        const string PropertyKind = "Kind";

        private string name;
        private string kind;
        private event PropertyChangedEventHandler onPropertyChanged;

        public Animal(string name, string kind)
        {
            this.name = name;
            this.kind = kind;
            this.onPropertyChanged += delegate(object sender , PropertyChangedEventArgs args)
            {
                Console.WriteLine("PropertyName:{0};OldValue:{1};NewValue:{2}", args.PropertyName , args.OldValue, args.NewValue);
            };
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                this.onPropertyChanged(this, new PropertyChangedEventArgs(PropertyName, name, value));
                name = value;
            }
        }

        public string Kind
        {
            get
            {
                return kind;
            }
            set
            {
                this.onPropertyChanged(this, new PropertyChangedEventArgs(PropertyKind, kind, value));
                kind = value;
            }
        }
    }
}
